package cn.maihe.elg.operation.repository.entity;

import cn.maihe.framework.starter.base.sql.BaseEntity;
import cn.maihe.framework.starter.base.sql.MapperInterface;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@TableName("t_guarantee")
@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
@MapperInterface("cn.maihe.elg.operation.repository.mapper.GuaranteeMapper")
public class GuaranteeDO extends BaseEntity {
    /**
     * 主键
     */
    @TableId(type = IdType.ID_WORKER)
    private Long id;

    /**
     * 交易中心主键id
     */
    @TableField(value = "center_id")
    private Long centerId;

    /**
     * 机构id
     */
    @TableField(value = "org_id")
    private Long orgId;

    /**
     * 保函编号
     */
    @TableField(value = "guarantee_no")
    private String guaranteeNo;

    /**
     * 保函校验码
     */
    @TableField(value = "guarantee_check_no")
    private String guaranteeCheckNo;

    /**
     * 保函文件
     */
    @TableField(value = "guarantee_file")
    private String guaranteeFile;

    /**
     * 保函文件md5
     */
    @TableField(value = "guarantee_file_md5")
    private String guaranteeFileMd5;

    /**
     * 开函机构主键
     */
    @TableField(value = "institution_id")
    private Long institutionId;

    /**
     * 交易中心订单号
     */
    @TableField(value = "center_order_id")
    private String centerOrderId;

    /**
     * 受理订单号
     */
    @TableField(value = "accept_order_no")
    private String acceptOrderNo;

    /**
     * 申请开函订单号
     */
    @TableField(value = "apply_order_no")
    private String applyOrderNo;

    /**
     * 保函服务起始时间
     */
    @TableField(value = "service_begin_time")
    private Date serviceBeginTime;

    /**
     * 保函服务终止时间
     */
    @TableField(value = "service_end_time")
    private Date serviceEndTime;

    /**
     * 投标保证金(分)
     */
    @TableField(value = "bid_bond")
    private Long bidBond;

    /**
     * 保费(分)
     */
    @TableField(value = "amount")
    private Long amount;

    /**
     * 保费费率(%)
     */
    @TableField(exist = false)
    private String rate;

    /**
     * 保函类型数据字典
     */
    @TableField(value = "guarantee_type")
    private String guaranteeType;

    /**
     * 保函品种数据字典
     */
    @TableField(value = "guarantee_category")
    private String guaranteeCategory;

    /**
     * 招标项目编号
     */
    @TableField(value = "project_code")
    private String projectCode;

    /**
     * 招标项目名称
     */
    @TableField(value = "project_name")
    private String projectName;

    /**
     * 标段编号
     */
    @TableField(value = "section_code")
    private String sectionCode;

    /**
     * 标段名称
     */
    @TableField(value = "section_name")
    private String sectionName;

    /**
     * 出函机构名称
     */
    @TableField(value = "guarantor_name")
    private String guarantorName;

    /**
     * 招标商名称
     */
    @TableField(value = "tenderer")
    private String tenderer;

    /**
     * 申请企业名称
     */
    @TableField(value = "bid_customer_name")
    private String bidCustomerName;

    /**
     * 保函状态数据字典
     */
    @TableField(value = "guarantee_status")
    private Integer guaranteeStatus;

    /**
     * 备注说明
     */
    @TableField(value = "remark")
    private String remark;

    /**
     * 创建时间
     */
    @TableField(value = "gmt_create", fill = FieldFill.INSERT)
    private Date gmtCreate;

    /**
     * 更新时间
     */
    @TableField(value = "gmt_modified", fill = FieldFill.INSERT_UPDATE)
    private Date gmtModified;

    /**
     * 创建用户
     */
    @TableField(value = "user_create", fill = FieldFill.INSERT)
    private String userCreate;

    /**
     * 更新用户
     */
    @TableField(value = "user_modified", fill = FieldFill.INSERT_UPDATE)
    private String userModified;

    /**
     * 保函序列号
     */
    @TableField(value = "serial_num")
    private String serialNum;

    /**
     * 保函撤销(解保)时间
     */
    @TableField(value = "revoke_time")
    private Date revokeTime;

    /**
     * 出函时间
     */
    @TableField(value = "guarantee_time")
    private Date guaranteeTime;

    /**
     * 推送标识0未推送 1已推送 2 推送失败
     */
    @TableField(value = "push_flag")
    private Integer pushFlag;

    /**
     * 推送结果描述
     */
    @TableField(value = "push_resp_msg")
    private String pushRespMsg;

    public GuaranteeVo buildVo() {
        return new GuaranteeVo(id, centerId, orgId, guaranteeNo, guaranteeCheckNo, guaranteeFile, guaranteeFileMd5, institutionId, centerOrderId, acceptOrderNo, applyOrderNo, serviceBeginTime, serviceEndTime, bidBond, amount, rate, guaranteeType, guaranteeCategory, projectCode, projectName, sectionCode, sectionName, guarantorName, tenderer, bidCustomerName, guaranteeStatus, remark, gmtCreate, gmtModified, userCreate, userModified, serialNum, revokeTime, guaranteeTime, pushFlag, pushRespMsg);
    }

    public static GuaranteeDO of(GuaranteeVo vo) {
        return new GuaranteeDO(vo.getId(), vo.getCenterId(), vo.getOrgId(), vo.getGuaranteeNo(), vo.getGuaranteeCheckNo(), vo.getGuaranteeFile(), vo.getGuaranteeFileMd5(), vo.getInstitutionId(), vo.getCenterOrderId(), vo.getAcceptOrderNo(), vo.getApplyOrderNo(), vo.getServiceBeginTime(), vo.getServiceEndTime(), vo.getBidBond(), vo.getAmount(), vo.getRate(), vo.getGuaranteeType(), vo.getGuaranteeCategory(), vo.getProjectCode(), vo.getProjectName(), vo.getSectionCode(), vo.getSectionName(), vo.getGuarantorName(), vo.getTenderer(), vo.getBidCustomerName(), vo.getGuaranteeStatus(), vo.getRemark(), vo.getGmtCreate(), vo.getGmtModified(), vo.getUserCreate(), vo.getUserModified(), vo.getSerialNum(), vo.getRevokeTime(), vo.getGuaranteeTime(), vo.getPushFlag(), vo.getPushRespMsg());
    }
}
